<?php



namespace App\Services\Business\Models;

use App\Services\Business\Models\Base;

use App\Services\Member\Models\User;

class Favorite extends Base
{


    protected $table = 'favorites';

    protected $fillable = [
        'user_id','title','category_id','favorable_id','favorable_type'
    ];

    public function getFavorableTypeAttribute($favorableType)
    {

        return  substr($favorableType, strrpos($favorableType, "\\") + 1);

    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }


    public function favorable()
    {
        return $this->morphTo();
    }


}